package com.main.springannotation.C;

import com.main.springannotation.AB.AbInterface;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;

/**
 * Created by admin on 2017/5/1.
 */
@Component
public class CC {
    @PostConstruct //用来修饰一个非静态的void()方法
    //@PostConstruct修饰的方法会在new构造函数之后，init()方法之前
    public void doinit(){
            System.out.println("@PostConstruct调用该类new后初始化");
    }
    @PreDestroy //一般用不到这个调用
    public void destroy(){
        System.out.println("@PostConstruct该类销毁时调用");
    }

    //@Value("#{aa.a}")
    //private String c;

    @Value("#{aa.elString()}")
    private String eL;


    //错误用法${getProperties.driverClass}错误
    @Value("${driverClass}")
    private String driverClass;


    @Autowired
    @Qualifier("aa")
    private AbInterface ab;
    public void print(){
        ab.save();
    }
    public  void printC(){
        System.out.println(eL);
    }

    public  void getDriverClass(){
        System.out.println("取properties文件中的driverClass:"+driverClass);
    }

}
